package cn.sundat.service;


import java.util.List;

import javax.annotation.Resource;

import org.hibernate.criterion.DetachedCriteria;
import org.springframework.transaction.annotation.Transactional;

import cn.sundat.dao.NewsDao;
import cn.sundat.model.Category;
import cn.sundat.model.News;
import cn.sundat.model.PageBean;

@Transactional
public class NewsServiceImpl implements NewsService {

	@Resource(name="newsDao")
	private NewsDao newsDao;
	
	//添加一条文章或者新闻
	public void save(News news) {
		newsDao.save(news);
	}

	public PageBean<News> findByPage(Integer currPage, Integer pageSize, DetachedCriteria criteria) {
		return newsDao.findByPage(currPage,pageSize,criteria);
	}

	public List<News> findByCategory(Category category) {
		return newsDao.findByCategory(category);
	}
	
	public List<News> findByAdminCategory(DetachedCriteria criteria) {
		return newsDao.findByAdminCategory(criteria);
	}

	public void del(Long news_id) {
		newsDao.del(news_id);
	}

	public News findById(Long news_id) {
		return newsDao.findById(news_id);
	}

	public void update(News news) {
		 newsDao.update(news);
	}

	public List<News> findImgByCategory(Category c) {
		return newsDao.findImgByCategory(c);
	}

	@Override
	public PageBean<News> findVipNews(Integer currPage, Integer pageSize, DetachedCriteria criteria) {
		return newsDao.findVipNews(currPage,pageSize,criteria);
	}
	
	
	
}
